package lc_2956_找到两个数组中的公共元素;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;

public class Solution {
    /**
     * @param nums1
     * @param nums2
     * @return
     */
    public int[] findIntersectionValues(int[] nums1, int[] nums2) {
        Set<Integer> s1 = Arrays.stream(nums1).boxed().collect(Collectors.toSet());
        Set<Integer> s2 = Arrays.stream(nums2).boxed().collect(Collectors.toSet());
        return new int[] { (int) Arrays.stream(nums1).boxed().filter(s2::contains).count(),
                (int) Arrays.stream(nums2).filter(s1::contains).count() };

    }

    // return new int[] { Arrays.stream(nums1).boxed()
    // .collect(Collectors.partitioningBy(s -> s2.contains(s))).get(true).size(),
    // Arrays.stream(nums2).boxed()
    // .collect(Collectors.partitioningBy(s -> s1.contains(
    // s)))
    // .get(true).size() };
}